package com.example.designpatterns.observer;

/**
 * 假设猫是老鼠和狗的观察目标,老鼠和狗是观察者,猫叫老鼠跑,狗也跟着叫,使用观察者模式描述该过程。
 */
public class Client {
    public static void main(String[] args) {
        MySubject subject = new Cat();

        MyObserver obs1, obs2, obs3, obs4;
        obs1 = new Mouse();
        obs2 = new Mouse();
        obs3 = new Dog();
        obs4 = new Pig();

        subject.attach(obs1);
        subject.attach(obs2);
        subject.attach(obs3);
        subject.attach(obs4);

        subject.cry();
    }
}